<form action="service.php" method="post">

    <input type="hidden" name="id" value="{if $object.srv_id!=0}{$object.srv_id}{else}{$object.id}{/if}"/>
    <table>
	<tr>
	    <td align="right">Услуга:</td>
	    <td>
		<select name="service_name_id">
		{foreach from=$service_names item=sn}
		    <option value="{$sn.id}" {if $object.service_name_id==$sn.id}selected{/if}>{$sn.service_name}</option>
		{/foreach}
		</select>

		{if $object.service_name_id==3}
		<table class="service-options ui-state-default" id="service-name-3">
		    <tr>
			<td align="right"><strong>Номер телефона:</strong></td>
			<td><input type="text" name="phone_number" value="{$object.phone_number}"/></td>
		    </tr>
		    <tr>
			<td align="right"><strong>Тариф:</strong></td>
			<td>
			    <select name="phone_rate_id">
			    {foreach from=$phone_rates item=rate}
				<option value="{$rate.id}" {if $rate.id==$object.phone_rate_id}selected{/if}>{$rate.rate_name}</option>
			    {/foreach}
			    </select>
			</td>
		    </tr>
		</table>
		{/if}

		{if $object.service_name_id==30}
		<table class="service-options ui-state-default" id="service-name-30">
		    <tr>
			<td align="right" colspan=3><strong>Тариф:</strong></td>
			<td>
			    <select name="phone_rate_id">
			    {foreach from=$phone_rates item=rate}
				<option value="{$rate.id}" {if $rate.id==$object.phone_rate_id}selected{/if}>{$rate.rate_name}</option>
			    {/foreach}
			    </select>
			</td>
		    </tr>
		    <tr>
			<td align="right" colspan=3><strong>Количество каналов:</strong></td>
			<td><input type="text" name="number_of_channels" value="{$object.number_of_channel}"/></td>
		    </tr>
		    <tr>
			<td align="right"><strong>Местная связь:</strong></td>
			<td colspan=3>
			    <select name="city_uplink_id">
			    	{foreach from=$city_uplinks item=city_uplinks}
					<option value="{$city_uplinks.id}" {if $city_uplinks.name==$object.city_name}selected{/if}>{$city_uplinks.name}</option>
			    	{/foreach}
			    	<option value="NULL" {if $object.city_name==""}selected{/if}>запрещено</option>
			    </select>
			</td>
		    </tr>
		    <tr>
			<td align="right"><strong>Зона мобильные:</strong></td>
			<td>
			    <select name="zona_mobile_uplink_id">
			    {foreach from=$zona_mobile_uplinks item=zona_mobile_uplinks}
				<option value="{$zona_mobile_uplinks.id}" {if $zona_mobile_uplinks.name==$object.zona_mobile_name}selected{/if}>{$zona_mobile_uplinks.name}</option>
			    {/foreach}
			    <option value="NULL" {if $object.zona_mobile_name==""}selected{/if}>запрещено</option>
			    </select>
			</td>
			<td align="right"><strong>Зона мобильные резерв:</strong></td>
			<td>
			<select name="zona_mobile_uplink_reserve_id">
			{foreach from=$zona_mobile_uplinks_reserve item=zona_mobile_uplinks}
			<option value="{$zona_mobile_uplinks.id}" {if $zona_mobile_uplinks.name==$object.zona_mobile_name_reserve_name}selected{/if}>{$zona_mobile_uplinks.name}</option>
			{/foreach}
			<option value="NULL" {if $object.zona_mobile_name_reserve_name==""}selected{/if}>запрещено</option>
			</select>
			</td>
		    </tr>
		    <tr>
		    <td align="right"><strong>Зона стационарные:</strong></td>
			<td>
			    <select name="zona_stationary_uplinks_id">
			    {foreach from=$zona_stationary_uplinks item=zona_stationary_uplinks}
				<option value="{$zona_stationary_uplinks.id}" {if $zona_stationary_uplinks.name==$object.zona_stationary_name}selected{/if}>{$zona_stationary_uplinks.name}</option>
			    {/foreach}
			    <option value="NULL" {if $object.zona_stationary_name==""}selected{/if}>запрещено</option>
			    </select>
			</td>
			<td align="right"><strong>Зона стационарные резерв:</strong></td>
			<td>
			<select name="zona_stationary_uplinks_reserve_id">
			{foreach from=$zona_stationary_uplinks_reserve item=zona_stationary_uplinks}
			<option value="{$zona_stationary_uplinks.id}" {if $zona_stationary_uplinks.name==$object.zona_stationary_uplink_reserve_name}selected{/if}>{$zona_stationary_uplinks.name}</option>
			{/foreach}
			<option value="NULL" {if $object.zona_stationary_uplink_reserve_name==""}selected{/if}>запрещено</option>
			</select>
			</td>
		    </tr>
		    <tr>
		    <td align="right"><strong>Междугородние:</strong></td>
			<td>
			    <select name="long_distance_uplinks_id">
			    {foreach from=$long_distance_uplinks item=long_distance_uplinks}
				<option value="{$long_distance_uplinks.id}" {if $long_distance_uplinks.name==$object.long_distance_name}selected{/if}>{$long_distance_uplinks.name}</option>
			    {/foreach}
			    <option value="NULL" {if $object.long_distance_name==""}selected{/if}>запрещено</option>
			    </select>
			</td>
			<td align="right"><strong>Междугородние резерв:</strong></td>
			<td>
			<select name="long_distance_uplinks_reserve_id">
			{foreach from=$long_distance_uplinks_reserve item=long_distance_uplinks_reserve}
			<option value="{$long_distance_uplinks_reserve.id}" {if $long_distance_uplinks_reserve.name==$object.long_distance_name_reserve}selected{/if}>{$long_distance_uplinks_reserve.name}</option>
			{/foreach}
			<option value="NULL" {if $object.long_distance_name_reserve==""}selected{/if}>запрещено</option>
			</select>
			</td>
		    </tr>
		    <tr>
		    <td align="right"><strong>Международные:</strong></td>
			<td>
			    <select name="international_uplinks_id">
			    {foreach from=$international_uplinks item=international_uplinks}
				<option value="{$international_uplinks.id}" {if $international_uplinks.name==$object.international_name}selected{/if}>{$international_uplinks.name}</option>
			    {/foreach}
			    <option value="NULL" {if $object.international_name==""}selected{/if}>запрещено</option>
			    </select>
			</td>
			<td align="right"><strong>Международные резерв:</strong></td>
			<td colspan=3>
			    <select name="international_uplinks_reserve_id">
			    {foreach from=$international_uplinks_reserve item=international_uplinks_reserve}
				<option value="{$international_uplinks_reserve.id}" {if $international_uplinks_reserve.name==$object.international_reserve_name}selected{/if}>{$international_uplinks_reserve.name}</option>
			    {/foreach}
			    <option value="NULL" {if $object.international_reserve_name==""}selected{/if}>запрещено</option>
			    </select>
			</td>
		    </tr>
		    <tr>
		    	<td align="right" colspan=2><strong>Включить привязку к IP адресу:</strong></td>
		    	<td><input colspan=2 type="checkbox" name="fix_ip_address_enable" value="1" {if $object.fix_ip_address_enable==1}checked{/if}/></td>
		    </tr>
		    <tr>
		    	<td align="right" colspan=2><strong>Привязанный IP адрес.:</strong></td>
		    	<td><input type="text" name="fix_ip_address" value="{$object.fix_ip_address}"/></td>
		    </tr>
		    <tr>
					<td align="right">Договор:</td>
					<td>
					    <select name="contract_id">
					    {foreach from=$contract_numbers item=contract_number}
						<option value="{$contract_number.id}" {if $object.contract_id==$contract_number.id}selected{/if}>{$contract_number.contract_number}</option
						</table>>
					    {foreachelse}
						<option class="ui-state-disabled" value=NULL>Нет договоров</option>
					    {/foreach}
					    </select>
					</td>
			</tr>
		</table>
		<table class="service-options ui-state-default" id="service-name-30">
			<tr>
		    	<td align="right" colspan=1><strong>Переадресация:</strong></td>
		    	<td><input colspan=1 type="checkbox" name="call_forward" value="1" {if $object.call_forward==1}checked{/if}/></td>
		    	<td align="right" colspan=1><strong>Номер для переадресации:</strong></td>
		    	<td><input type="text" name="forward_number" value="{$object.forward_number}"/></td>
		    	<td align="right" colspan=1><strong>Таймаут:</strong></td>
		    	<td><input type="text" name="forward_timeout" value="{$object.forward_timeout}"/></td>
		    </tr>
		</table>
		{/if}

	    </td>
	</tr>
	<tr>
	    <td align="right">Исполнитель:</td>
	    <td>
		<select name="executive_id">
		{foreach from=$executives item=executive}
		    <option value="{$executive.id}" {if $object.executive_id==$executive.id}selected{/if}>{$executive.executive_name}</option>
		{/foreach}
		</select>
	    </td>
	</tr>
	{if $object.service_name_id!=30}
	<tr>
	    <td align="right">Количество:</td>
	    <td><input type="text" name="quantity" value="{$object.quantity}"/></td>
	</tr>
	{/if}
	<tr>
	    <td align="right">Стоимость:</td>
	    <td><input type="text" name="cost" value="{$object.cost}"/></td>
	</tr>
	<tr>
	    <td align="right">Ежемесячная:</td>
	    <td><input type="checkbox" name="monthly" value="1" {if $object.monthly==1}checked{/if}/></td>
	</tr>
	<tr>
	    <td align="right">Начало:</td>
	    <td><input type="text" name="start_date" value="{$object.start_date}"/></td>
	</tr>
	<tr>
	    <td align="right">Конец:</td>
	    <td><input type="text" name="stop_date" value="{$object.stop_date}"/></td>
	</tr>
	<tr>
		<td align="right">Выставлять счет ежемесячно</td>
		<td><input type="text" name="date_of_invoice" value="{$object.date_of_invoice}"></td>
	</tr>
	<tr>
	    <td align="right">Отсрочка платежа</td>
		<td><input type="text" name="payment_delay" value="{$object.payment_delay}"></td>
	</tr>
	<tr>
	    <td colspan="2" align="center"><input type="submit" value="Сохранить"/></td>
	</tr>
</table>
</form>
